<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>HelloWorld</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>Computed option</h1>
    <hr>
    <div id="app">      
        <p>    {{ count }}</p>
    

            <p>
                <button @click="add(5)">add5</button>
            </p>           
            <p>
                <button @click="addE($event)">add $event</button>
            </p>
            <p><btn @click.native="add(5)"></btn></p>
            <!-- .native 调用构造器里面的原生方法-->
       
    </div>
    <!-- 外部调用  -->
    <button onclick="app.add()">外部ADD</button>
   
    <script type="text/javascript">
        var btn={
            template : ` <button>组件ADD</button>`
        };


        var app = new Vue({
            el:'#app',
            data:{
                count:1
            },
            components:{
                "btn" : btn
            },
            methods:{
                // methods,传值 
                add:function(num,event){
                    if (num == null){
                        this.count++;
                    }else{
                        this.count += num;
                    }
                    
                    // console.log(event);
                  
                },
                // methods,vue自带事件
                addE:function(event){
                    console.log(event);
                }
            }
        
        })
    </script>
</body>
</html>